<?php require_once('Connections/cnn.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_Recordset1 = "-1";
if (isset($_GET['IdImagen'])) {
  $colname_Recordset1 = $_GET['IdImagen'];
}
mysql_select_db($database_cnn, $cnn);
$query_Recordset1 = sprintf("SELECT * FROM slider WHERE IdImagen = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $cnn) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['email'])) {
  $loginUsername=$_POST['email'];
  $password=$_POST['password'];
  $MM_fldUserAuthorization = "Rol";
  $MM_redirectLoginSuccess = "index_r.php";
  $MM_redirectLoginFailed = "error.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_cnn, $cnn);
  	
  $LoginRS__query=sprintf("SELECT Email, Password, Rol FROM usuario WHERE Email=%s AND Password=%s",
  GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
   
  $LoginRS = mysql_query($LoginRS__query, $cnn) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
    
    $loginStrGroup  = mysql_result($LoginRS,0,'Rol');
    
	if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;	      

    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">

<title>Ventas</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<link href="css/estilo.css" rel="stylesheet" type="text/css"><!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- InstanceBeginEditable name="1" -->
  <!-- Skitter Styles -->
  <link href="css/styles.css" type="text/css" media="all" rel="stylesheet" />
  <link href="css/skitter.styles.css" type="text/css" media="all" rel="stylesheet" />
    <link rel="stylesheet" href="css/style.css" />
    <link rel="stylesheet" href="css/jquery-ui.css" />
  

  
  <!-- Skitter JS -->
  <script type="text/javascript" language="javascript" src="js/jquery-1.6.3.min.js"></script>
  <script type="text/javascript" language="javascript" src="js/jquery.easing.1.3.js"></script>
  <script type="text/javascript" language="javascript" src="js/jquery.animate-colors-min.js"></script>
  <script type="text/javascript" language="javascript" src="js/jquery.skitter.min.js"></script>
  <script type="text/javascript" language="javascript" src="js/menu.js"></script>
  <script src="JSLogin/jquery-ui.js"></script>
  <script src="JSLogin/login.js"></script>
   


   

 

<![endif]-->


<!-- InstanceEndEditable -->
</head>


<body>


<div class="container">
  <header>
    <img src="images/banner.png" width="960" height="194" />

     <div id="loginContainer">
              <a href="#" id="loginButton"><span>Login</span><em></em></a>
              <a href="registrarse.php" id="loginButton"><span>Registrarse</span><em></em></a>
            

                         <div id="loginBox">                
                       <form ACTION="<?php echo $loginFormAction; ?>" METHOD="POST" id="loginForm">
                        <fieldset id="body">
                            <fieldset>
                                <label for="email">Email</label>
                                <input type="text" name="email" id="email" />
                            </fieldset>
                            <fieldset>
                                <label for="password">Contraseña</label>
                                <input type="password" name="password" id="password" />
                            </fieldset>

                            <input type="submit" id="login" value="Iniciar Sesión" />
                            
                        </fieldset>
                        
                        </form>
                     </div>
          </div>

  </header>

    <ul class="menu">
            <li><a href="index.php">Home</a></li>
            <li><a href="Productos.php">Productos</a></li>
            <li><a href="#">Acerca</a></li>
            <li><a href="Contactenos.php">Contactanos</a></li>
        </ul>
 
   <br><br><br>

  <!-- InstanceBeginEditable name="2" -->
  <!--script del slider -->
  <script type="text/javascript" language="javascript">
    $(document).ready(function() {
      $('.box_skitter_large').css({width: 600, height: 400}).skitter({
        theme: 'clean',
        numbers_align: 'center',
        progressbar: true, 
        dots: true, 
        preview: true
      });
    });
  </script>

  <!-- script del menu -->
   <script type="text/javascript">
            $(document).ready(function() {
                $('.menu').tagdrop({tagPaddingTop: '60px',bgColor: '#B1CCED',bgMoverColor: '#7FB0F0',textColor: '#e0e0e0'});
            });
        </script>
  
    <div id="page">
    <div id="content">
      <div class="border_box">
        <div class="box_skitter box_skitter_large">
          <ul>
            <?php
            $con=mysql_query("select IdImagen from slider");
            while ($row=mysql_fetch_assoc($con)){

              for ($i = $row['IdImagen']; $i <= $row['IdImagen']; $i++){
              $consulta= mysql_query("select Imagen, Descripcion from slider where IdImagen = '$i'");
              $datos = mysql_fetch_assoc($consulta);
              
              $imagen= $datos['Imagen'];
              $descrip= $datos['Descripcion'];
              
              echo "<li>";
                echo " <img src='images/slider/$imagen' class='block' width='600' height='400'/><div class='label_text'><p>$descrip </p></div>";
        
               
              echo "</li>"; 
              $i++;
              
              
              }
            }
            
              
                     ?>
          
          
          </ul>
        </div>
      </div>
    </div>
  </div>
  <h1>Categorias</h1>
<div id="sidebar">
      <center><img src="images/nuevo.jpg" width="210" height="110"  /> </center>
      <a href="#"><h3>Nuevos Productos</h3></a>
    </div>
      <div id="sidebar2">
      <center><img src="images/descuento.jpg" width="210" height="110"  /> </center>
      <a href="#"><h3>Promociones</h3></a>
    </div>
    <div id="sidebar3">
      <center><img src="images/electrodomesticos.jpg" width="230" height="95"  /> </center>
      <a href="#"><h3>Electrodomesticos</h3></a>
    </div>
      <div id="sidebar4">
      <center><img src="images/audio.jpg" width="230" height="95"  /> </center>
      <a href="#"><h3>Audio y video</h3></a>
    </div>
    <div id="sidebar5">
      <center><img src="images/hogar.jpg" width="230" height="95"  /> </center>
      <a href="#"><h3>Hogar</h3></a>
      
    </div>
  

  
  
  <div class="content">
    
    
    
   </div>  

  <footer>
    <h3>Super Gangas</h3>
  </footer>
  <!-- end .container --></div>

</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($Recordset1);
?>
